package com.huangyi.order.controller;

import com.huangyi.api.ProductInterface;
import com.huangyi.model.ProductInfo;
import com.huangyi.order.api.ProductApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/product")
public class ProductApiController {

    @Autowired
    private ProductApi productApi;

    @RequestMapping("/{id}")
    ProductInfo getProductInfo(@RequestParam("id") Integer id) {
        return  productApi.getProductById(id);
    }
    @RequestMapping("/o1")
    public String returnId (@RequestParam("id") Integer id){
        return productApi.getProductByName1(id);
    }
    @RequestMapping("/o2")
    public String returnId2 (@RequestParam("name") String name,@RequestParam("id") Integer id){
        return productApi.getProductByName(id,name);
    }
    @RequestMapping("/o3")
    public String returnId3 (ProductInfo productInfo){
        return productApi.getInfo(productInfo);
    }
    @RequestMapping("/o4")
    public String returnId4 (ProductInfo productInfo){
        return productApi.getInfoJson(productInfo);
    }

}
